package com.fc.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author 作者相关信息
 * @version 1.0 版本信息
 * @description 类的描述
 * @date 2021/12/18 15:44
 */
@Configuration
public class Swagger2Config {

    @Bean
    public Docket createRestApi(){
        return  new Docket(DocumentationType.SWAGGER_2)//制定api类型为swagger2类型
                .apiInfo(apiInfo()) //定义api文档汇总信息,获取apiInfo()返回的Bean信息
                .select().apis(RequestHandlerSelectors.basePackage("com.fc.controller"))//扫描哪个包下面 //RequestHandlerSelectors.withClassAnnotation(Api.class)存在注解的都都会拿取到
                .paths(PathSelectors.any())//所有接口
                // 可以根据url路径设置哪些请求加入文档，忽略哪些请求
                .build();
    }


    @Bean
    public ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("ZffcBootApi接口")
                .contact(new Contact("张空谷","www.baidu.com","1446097473@qq.com"))
                .description("测试文档")
                .version("1.0.0")
                .termsOfServiceUrl("www.dai.com")
                .build();
    }
}
